﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Framework.Library.Base.Base;
using Framework.Library.Core.Utils.URLBuilder;

namespace Framework.Portal.Layouts.Admin.Components.BGTT.Courses
{
    public partial class CoursesFollower : BaseControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetActiveTab();
            }
        }

        private void GetActiveTab()
        {
            int courseId;
            int.TryParse(Request.QueryString["c"], out courseId);
            if (courseId > 0)
            {
                btn1.Enabled = true;
                btn2.Enabled = true;
                btn3.Enabled = true;
                btn4.Enabled = true;
                btn5.Enabled = true;
                btn6.Enabled = true;
            }
        }
        protected void ActiveTab(object sender, EventArgs e)
        {
            int courseId;
            int.TryParse(Request.QueryString["c"], out courseId);
            var sends = sender as LinkButton;
            if (sends != null)
            {
                var urlParser = new SimpleURLParameterParser(Request.RawUrl);
                var lstUrl = new Dictionary<string, string>();
                lstUrl.Add("t", sends.CommandArgument);
                if (Convert.ToInt32(sends.CommandArgument) > 0)
                    lstUrl.Add("c", courseId.ToString());
                Response.Redirect(urlParser.CreateQueryString(lstUrl));
            }
        }
    }
}